package com.woniu.apartment.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.woniu.apartment.myVo.PopularApartmentVo;
import com.woniu.apartment.vo.ApartmentVo;
import com.woniu.apartment.domain.ApartmentMain;
import com.woniu.apartment.service.IApartmentMainService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 公寓Controller
 * 
 * @author yy
 * @date 2023-04-03
 */
@RestController
@RequestMapping("/apartment/tbapartmentmain")
@Api("公寓管理")
public class ApartmentMainWebController extends BaseController
{
    @Autowired
    private IApartmentMainService apartmentMainService;

    /**
     * 查询公寓列表
     */
    //@PreAuthorize("@ss.hasPermi('apartment:tbapartmentmain:list')")
    @GetMapping("/web/list")
    @ApiOperation("公寓分页查询")
    public TableDataInfo list(ApartmentMain apartmentMain)
    {
        startPage();
        List<ApartmentMain> list = apartmentMainService.selectApartmentMainList(apartmentMain);
        return getDataTable(list);
    }


    @GetMapping("/web/searchNearbyPopularCityApartmentList")
    @ApiOperation("首页热门城市附近住宿查询")
    public TableDataInfo searchNearbyPopularCityApartmentList(String cityId)
    {

        System.out.println("城市id:"+cityId);
        List<PopularApartmentVo> list = apartmentMainService.searchNearbyPopularCityApartmentList(cityId);
        System.out.println(list);
        return getDataTable(list);
    }

    @GetMapping("/web/SearchCityOrUniversityOrApartmentNameForList")
    @ApiOperation("公寓分页查询")
    public TableDataInfo SearchCityOrUniversityOrApartmentNameForList(String SearchContent)
    {
        startPage();
        List<PopularApartmentVo> list = apartmentMainService.SearchCityOrUniversityOrApartmentNameForList(SearchContent);
        return getDataTable(list);
    }
    @GetMapping(value = "web/queryApartmentById")
    @ApiOperation("根据主键查询公寓")
    public AjaxResult getInfo( Long apartmentId)
    {
       ApartmentVo apartment= apartmentMainService.selectAllInfoById(apartmentId);
        return AjaxResult.success(apartment);
    }


}
